<?php
function __autoload($class_name) {
    require '../private/'.$class_name.'.php';
}

	//$jsonData = getDataAsJson($_GET['symbol']);
	//echo $_GET['callback'] . '(' . $jsonData . ');';
	// prints: jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"});

	$jsonpMode = (strlen($_GET['callback']) > 0);
try{
    $db = new dbaseManager();
    $list = $db->getProductList();

	$output = ($jsonpMode) ? $_GET['callback'].'([' : '';

	foreach($list as $item){
		if($jsonpMode){
			$output .= "\"$item\" ,";
		}else{
			$output .= "$item</br>";
		}
	}
	
	if($jsonpMode){
		$output = substr($output, 0, strlen($output) - 1);
		$output .= '])';
	}
	
	echo $output;
}catch(Exception $e){
    print "ERROR:  ".$e->getMessage()."</br>".
          "please check <a href=\"http://projects.developer.nokia.com/iap_sample/wiki\">Product Store API</a>";
}
   
?>
